﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class openLotterEdit : System.Web.UI.Page
{

    protected long id = ReadRequest.RequestLong("id");


    protected void Page_Load(object sender, EventArgs e)
    {
       
        if (!IsPostBack)
        {
            inidata();
          
        }
       
    }


    private void inidata()
    {

        Model.LotteryAnnouncement model = BLL.LotteryAnnouncement.GetModel(id);
        if (model != null)
        {
            textQS.Text = model.LotteryQS;
            txtNo.Text = model.LotteryNo;
            oneCount.Text = model.oneCount.ToString();
            oneMoney.Text = model.oneMoney.ToString();
            twoCount.Text = model.twoCount.ToString();
            twoMoney.Text = model.twoMoney.ToString();
            threeCount.Text= model.threeCount.ToString();
            threeMoney.Text = model.threeMoney.ToString();
            fourCount.Text = model.fourCount.ToString();
            fourMoney.Text = model.fourMoney.ToString();
            fiveCount.Text = model.fiveCount.ToString();
            fiveMoney.Text = model.fiveMoney.ToString();
            sixCount.Text = model.sixCount.ToString();
            sixMoney.Text= model.sixMoney.ToString();
            sevenCount.Text = model.sevenCount.ToString();
            sevenMoney.Text = model.sevenMoney.ToString();
            twoSCount.Text= model.twoSCount.ToString();
            twoSMoney.Text = model.twoSMoney.ToString();
            sumMoney.Text= model.sumMoney.ToString();
            jiangChi.Text = model.jiangChi.ToString();
        }




    }
    protected void btn_submit_Click(object sender, EventArgs e)
    {
        save_Newscont();
    }

    private void save_Newscont()
    {
        Model.LotteryAnnouncement model = BLL.LotteryAnnouncement.GetModel(id);
        //获取登录信息
        Model.Manageadmin loginUserInfo_cur = BLL.CMember.ManageadminLoginInfo();
        //没有登录
        if (loginUserInfo_cur == null)
        {
            alertmessageAndGoback("保存失败");
            return;
        }

        if (model != null)
        {
            model.LotteryQS = textQS.Text;
            model.LotteryNo = txtNo.Text;
            model.oneCount = int.Parse(oneCount.Text);
            model.oneMoney = decimal.Parse(oneMoney.Text);
            model.twoCount = int.Parse(twoCount.Text);
            model.twoMoney = decimal.Parse(twoMoney.Text);
            model.threeCount = int.Parse(threeCount.Text);
            model.threeMoney = decimal.Parse(threeMoney.Text);
            model.fourCount = int.Parse(fourCount.Text);
            model.fourMoney = decimal.Parse(fourMoney.Text);
            model.fiveCount = int.Parse(fiveCount.Text);
            model.fiveMoney = decimal.Parse(fiveMoney.Text);
            model.sixCount = int.Parse(sixCount.Text);
            model.sixMoney = decimal.Parse(sixMoney.Text);
            model.sevenCount = int.Parse(sevenCount.Text);
            model.sevenMoney = decimal.Parse(sevenMoney.Text);
            model.twoSCount = int.Parse(twoSCount.Text);
            model.twoSMoney = decimal.Parse(twoSMoney.Text);
            model.sumMoney = decimal.Parse(sumMoney.Text);
            model.jiangChi = decimal.Parse(jiangChi.Text);

            if (BLL.LotteryAnnouncement.Update(model) > 0)
            {
                alertmessageAndGo("保存成功！", "/manage/openLotteryNews.aspx");
                return;
            }
            else
            {
                alertmessageAndGoback("保存失败");
                return;
            }

        }

    }

    private void alertmessageAndGo(string message, string url)
    {
        System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">alert('" + message + "');window.location.href = '" + url + "';</script>");
    }

    private void alertmessageAndGoback(string message)
    {
        System.Web.HttpContext.Current.Response.Write("<script type=\"text/javascript\">alert('" + message + "');history.go(-1);</script>");
    }
}